const EventEmmiter = require('events');
class Person extends EventEmmiter{

    constructor(name){
        super();

        this.name = name ;
        this.age = 0;
        this.growup();
    }

    growup () {
        setInterval(()=>{
            this.age ++

            this.emit('aa')
        },1000)
    }

}

let p1 = new Person('zhangsan');
console.log(p1)

p1.addListener('aa', ()=>{
    console.log(p1.age)
})